<?php

namespace app\common\cachemodel\zl2;

use app\common\model\BaseCache;

class Zl2FortuneDayTarotText extends BaseCache
{
    protected $table = 'wechat_backup_07_18_14_43_00.zl2_fortune_day_tarot_text';

    protected $cacheModel = 'fortune.tarot_card_text';

    /**
     * 批量获取 数据
     * @param $ids
     * @param $type
     * @param $sortType
     * @return array|false|string|void
     */
    public function getInfoByIdsInData($ids, $type, $sortType)
    {
        try
        {
            $data = $this->where(['card_id' => ['in', $ids]])->order("card_id {$sortType}")->column('name,title,career,academic,feelings', 'card_id');
        }
        catch (\Exception $e)
        {
            $data = [];
        }

        return $data;
    }

    public function batchGetInfoByIds($cids, $field = [])
    {
        $resData = parent::batchGetInfoByIds($cids, $field);

        return $this->dataInit($resData);
    }

    /**
     * 数据初始化
     * @param array $data
     * @return array
     */
    public function dataInit(array $data)
    {
        foreach ($data as $index => $itemData)
        {
            $data[$index] = arrayKeyData2int($itemData, ['card_id']);
        }

        return $data;
    }
}